package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCat")
public class ItemController {

 @Autowired
 private ItemService itemService;

@GetMapping("/findItemCatList/{type}")
 public SysResult findItemCatList(@PathVariable Integer type){
 List<ItemCat> catList=itemService.findItemCatList(type);
 return SysResult.success(catList);
}

@PutMapping("/status/{id}/{status}")
 public SysResult updateStatus(ItemCat itemCat){
 itemService.updateStatus(itemCat);
 return SysResult.success();
}

// @DeleteMapping("/deleteItemCat")
// public SysResult deleteItem(ItemCat itemCat){
//  itemService.deleteItem(itemCat);
//  return SysResult.success();
// }
//
 @DeleteMapping("/deleteItemCat")
 public SysResult deleteItem(Integer id,Integer level){
  itemService.deleteItem(id,level);
  return SysResult.success();
 }

 @PostMapping("/saveItemCat")
 public SysResult addItem(@RequestBody ItemCat itemCat){
  itemService.addItem(itemCat);
  return SysResult.success();
 }

}
